using Ordering.Application.Orders.Contracts;
using Ordering.Domain.Orders;

namespace Ordering.Application.Orders.GetOrders;

internal static class OrderMappings
{
    public static OrderResponse ToResponse(this Order order)
    {
        return new OrderResponse(
            order.Id,
            order.UserId,
            order.Total,
            order.Status,
            order.CreatedAt,
            order.Items
                .Select(item => new OrderItemResponse(
                    item.ProductId,
                    item.ProductName,
                    item.UnitPrice,
                    item.Quantity))
                .ToArray(),
            order.ShippingAddress,
            order.Notes);
    }
}
